{extend name="public/base" /}

{block name="title"}<title>日常奖扣查询</title>{/block}

{block name="pjax_container"}
<style>
    .col-sm-2{
        width: 23.666667%;
        height: 33px;
        line-height: 40px;
        padding-top: 15px;
    }
    .col-sm-7{
        padding-top: 15px;
    }
    tr>th,
    td {
        text-align: center;
    }
    .layui-layer-content{
        padding: 15px;
    }
    .btn-group-xs>.btn,
    .btn-xs {
        padding: 5px;
        margin: 0 5px;
    }

    .content-header>.breadcrumb>li{
        color: #999;
    }
    .content-header>.breadcrumb>.active{
        color: #666;
    }
    .content-header{
        height: 51px;

    }
    
    .delete-one{
        background-color: ff4141 !important;
        margin-left: 15px;
        border-radius: 6px;
    }
    .sreachs{
        margin-right: 10px;
        background-color: #1890FF;
        color: #fff;
    }

    .form-control{
        width: 90%;
        border-radius: 8px;
    }
  
    .timepicker{
        margin: 10px 5px !important;
    }
.box-header.with-border {
    border-bottom: 0px solid #f4f4f4;
}
.select2-container--default .select2-selection--single, .select2-selection .select2-selection--single {
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 6px 12px;
    height: 34px;
    width: 220px;
}

.advancedQuery{
    width: 100%;
    height: 300px;
    display: none;
}
   .advancedQuery  label{
       margin-top: 18px;
       height: 35px;
       display: flex;
       justify-content: flex-start;

   }
      .advancedQuery  label span{
            width: 80px;
            line-height: 35px;
            flex-shrink: 1;
      }
   .advancedQuery  label input{
       width: 230px;
          height: 100%;
          border-radius: 6px;
          border: none;
          border: 1px solid #eee;
          padding-left: 20px;
   }
   .table-responsive{
       background-color: #fff;
   }
   .tpl-list-table_header{
    display: flex;
    justify-content: space-between;
    padding: 7px 15px 7px 33px;
    border: 1px solid #91d5ff;
    background-color: #e6f7ff;
    border-radius: 4px;
    margin-bottom: 16px;
    position: relative;
    height: 45px;
    line-height: 35px;
   
}
select{
    width: 230px;
          height: 100%;
          border-radius: 6px;
          border: none;
          border: 1px solid #eee;
          padding-left: 20px;
}
.modal-content{
    margin-top: 150px;
    width: 855px;
    height: 700px;

}
.modal-body{
    padding: 27px;
    width: 856px;
    height: 570px;
    display: flex;
}
.modal-right{
    flex: 1;
    height: 104%;
    border: 1px solid #eee;
    margin-left: 30px;
}
.modal-left{
    width: 66%;
    height: 100%;
   
}
.modal-right>h4{
    width: 100%;
    display: flex;
    justify-content: space-around;
}
.form-control{
    border-radius: 6px;
}
.table-body{
    width: 530px;
    height: 470px;
    border-radius: 6px;
    background-color: #eee;
}
.table-left{
    margin-right: 2%;
    width: 49%;
         height: 100%;
       float: left;
         border: 1px solid #eee;
    background-color: #fff;
}
.table-right{
       width: 49%;
         height: 100%;
           border: 1px solid #eee;
          float: left;
       background-color: #fff;
}

.layui-tree-entry{
    height: 100%;
    width: 100%;
    padding-right: 10px;
    line-height: 24px;
   
}
.table-right>p{
     text-align: center;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 14px;
}
.table-right>h4{
      text-align: center;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 14px;
   
}
.table-right>p>span{
      text-align: center;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 14px;
    width: 80%;
    display: inline-block;
    letter-spacing: 1px;
   
}
input[type=checkbox], input[type=radio] {
    margin-top: 11px;
}

.modal-right h4{
    width: 100%;
    font-size: 14px;
    text-align: center;
}
.move{
    width: 524px;
    height: 283px;
}


.magic-radio,
.magic-checkbox {
	position: absolute;
	display: none;
    
}
 

 
.magic-radio + label,
.magic-checkbox + label {
	position: relative;
	display: block;
	padding-left: 30px;
	cursor: pointer;
 
}
 
.magic-radio + label:before,
.magic-checkbox + label:before {
	position: absolute;
	top: 0px;
	left: 0;
	display: inline-block;
	width: 20px;
	height: 20px;
        margin-top: 5px;
	content: '';
	border: 1px solid #c0c0c0;
}
.magic-checkbox + label:before{
    	top: -5px;
}
.magic-radio + label:after,
  .magic-checkbox + label:after {
	position: absolute;
	display: none;
	content: '';
        margin-top: 5px;
}


 
.magic-radio:checked + label:after,
.magic-checkbox:checked + label:after {
	display: block;
}
.magic-radio + label:before {
	border-radius: 50%;
}
.magic-radio + label:after {
	top: 6px;
	left: 6px;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #3e97eb;
}
.magic-radio:checked + label:before {
	border: 1px solid #3e97eb;
}
.magic-radio:checked[disabled] + label:before {
	border: 1px solid #c9e2f9;
}

.magic-checkbox + label:before {
	border-radius: 3px;
}
.magic-checkbox + label:after {
	top: 2px;
	left: 7px;
	box-sizing: border-box;
	width: 6px;
	height: 12px;
	transform: rotate(45deg);
	border-width: 2px;
	border-style: solid;
	border-color: #fff;
	border-top: 0;
	border-left: 0;
}
.magic-checkbox + label:after {
    top: -2px;
}
.magic-checkbox:checked + label:before {
    border: #1890FF;
    background: #1890FF;
}
.magic-checkbox:checked[disabled] + label:before {
	border: #1890FF;
    background: #1890FF;
}
.btn-primary{
    background-color: #1890FF;
}
</style>

<section class="content-header">
    <ol class="breadcrumb">
        <li>积分管理</li>
        <li class="active">日常奖扣查询2021年之前历史数据查询</li>
    </ol>
</section>

<section class="content">
    <div class="row" >
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <div class="pull-left">
                        <div class="">
                            <form action="{:url('daily_2021')}" method="get" pjax-search="" id="form1">
                                <input type="hidden" name="page" value="1" />
                                <div class="input-group input-group-sm">
                                    <div style="float: right; display:flex;flex-wrap: wrap;align-items:center;"  id="box-title">
                                        <select class="select2" name="month" style="width: 220px;display: inline-block;margin: 0px 5px;margin-right: 10px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                            <option value="1" {if condition="input('month') == 1"}selected{/if}>本月</option>
                                            <option value="2" {if condition="input('month') == 2"}selected{/if}>上月</option>
                                            <option value="3" {if condition="input('month') == 3"}selected{/if}>最近两月</option>
                                        </select>
                                        <div class="xyqk_input">
                                            <input type="text" name="department_name" value="{:input('get.department_name','')}" class="department_name_less" placeholder="选择部门"  style="display: inline-block;width: 150px;margin: 0 10px;padding-left: 5px;border: 1px solid #eee;height: 34px;line-height:34px;border-radius: 6px;" autocomplete="off" >
                                            <input type="hidden" name="department_id" value="{:input('get.department_id','')}" class="department_id_less" autocomplete="off" >
                                                <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                        </div>
                                        
                                        <!-- <div style="display: inline-block;width: 150px;margin: 0px 10px;padding-left: 5px;border: 1px solid #ccc;height: 35px;line-height:35px;border-radius: 6px;" name="name" class="things_check_multiple" >选择事件</div> -->
                                        <input type="text"  name="things_check_name" value="{$event_info_num??''}" class="things_check_multiple" placeholder="选择事件" autocomplete="off" style="display: inline-block;width: 150px;margin-right:10px;padding-left: 5px;border: 1px solid #eee;height: 34px;line-height:34px;border-radius: 6px;" >
                                        {if condition="isset($event_info)"}
                                            {volist name="event_info" id="v"}
                                                <input type="hidden" name="event_ids[]" data_name="{$v.name}" value="{$v.id}" data_type="{$v.show_cate_name}">
                                            {/volist}
                                        {/if}
                                        <label  style="display:flex; width: 340px;margin-bottom: 0px;line-height: 34px;">
                                            <span style="width: 100px;">过滤启动分:</span>
                                            <select class="select2" name="base_integral" style="width: 220px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                                <option value="1" {if condition="input('base_integral', '1') == 1"}selected{/if} >是</option>
                                                <option value="0" {if condition="input('base_integral', '1') == 0"}selected{/if} >否</option>

                                            </select>
                                        </label>
                                        <label  style="display:flex; width: 340px;margin-bottom: 0px;line-height: 34px;">
                                            <span style="width: 100px;">过滤工龄分:</span>
                                            <select class="select2" name="working_age_integral" style="width: 220px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                                <option value="1" {if condition="input('working_age_integral', '1') == 1"}selected{/if}  >是</option>
                                                <option value="0" {if condition="input('working_age_integral', '1') == 0"}selected{/if} >否</option>

                                            </select>
                                        </label>
                                    </div> 
                                </div>
                                <div class="pull-left box-title" style="margin-top: 10px;">
                                    <button type="submit" class="btn btn-default sreachs">
                                            <i class="fa fa-search"></i> 查询
                                    </button>
                                    <a href="{:url('daily_2021')}" class="btn btn-default sreachs">
                                            <i class="fa fa-repeat"></i> 重置
                                    </a>

                                </div>




                            </form>
                        </div>
                    </div>
                    <div class="pull-right">
                        <button style="border: none; width: 80px;height: 35px;background-color: #fff;color: #1890FF;" id="Query">高级查询</button>
                        <!--<button class="btn btn-sm btn-primary"><i class="fa fa-cog"></i> 积分过滤设置</button>-->
                        <a href="javascript:;" class="btn btn-sm btn-primary" id="sort"><i class="fa fa-list-alt"></i> 当前条件排名</a>
                        <a href="javascript:;" class="btn btn-sm btn-primary" id="import_a"><i class="fa fa-cloud-upload"></i> 导出</a>
                    </div>
                </div>

                <form class="gjsx" action="{:url('daily_2021')}" method="GET" id="form2">
                    <input type="hidden" name="page" value="1" />
                    <div class="advancedQuery">
                        <label class="col-sm-3" for="">
                            <span>事件类型:</span>
                            <div class="xyqk_input">
                                <input type="text" name="things_type_check" class="things_type_check" value="{:input('get.things_type_check','')}" placeholder="选择事件类型" autocomplete="off">
                                <input type="hidden" name="type_event_id" value="{:input('get.type_event_id','')}" class="things_type_check_id">
                                <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>
                        </label>
                        <label class="col-sm-3" for="">
                            <span>初审人:</span>
                            <div class="xyqk_input">
                                <input type="text" name="first_check_user_name" value="{:input('get.first_check_user_name','')}" class="first_check_user_name" placeholder="请输入姓名">
                                <input type="hidden" name="first_check_user_id" value="{:input('get.first_check_user_id','')}" class="first_check_user_id">
                                <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>
                            
                        </label>
                        <label class="col-sm-3" for="">
                            <span>终审人:</span>
                            <div class="xyqk_input">
                                <input type="text" name="last_check_user_name" value="{:input('get.last_check_user_name','')}" class="last_check_user_name" placeholder="请输入姓名">
                                <input type="hidden" name="last_check_user_id" value="{:input('get.last_check_user_id','')}" class="last_check_user_id">
                                <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>
                            
                        </label>
                        <label class="col-sm-3" for="">
                            <span>记录人:</span>
                            <div class="xyqk_input">
                                <input type="text" name="record_user_name" value="{:input('get.record_user_name','')}" class="record_user_name" placeholder="请输入姓名">
                                <input type="hidden" name="record_user_id" value="{:input('get.record_user_id','')}" class="record_user_id">
                                <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>
                            
                        </label>
                        <label class="col-sm-3" for="">
                            <span>事件名称:</span>
                            <input type="text" class="things_check_multiple" value="{$event_info_num??''}" placeholder="选择事件" autocomplete="off">
                            <!-- <input type="hidden" name="event_ids[]"> -->
                            {if condition="isset($event_info)"}
                                {volist name="event_info" id="v"}
                                    <input type="hidden" name="event_ids[]" data_name="{$v.name}" value="{$v.id}" data_type="{$v.show_cate_name}">
                                {/volist}
                            {/if}
                        </label>
                        <label class="col-sm-3" for="">
                            <span>A分区间:</span>
                            <input type="text" name="integral_a_start" value="{:input('get.integral_a_start','')}" style="width: 100px;" placeholder="起始区间">
                            <span style="line-height: 35px;margin: 0 5px;width: unset;">~</span>
                            <input type="text" name="integral_a_end"  value="{:input('get.integral_a_end','')}" style="width: 100px;" placeholder="终止区间">
                        </label>
                        <label class="col-sm-3" for="">
                            <span>B分区间:</span>
                            <input type="text" name="integral_b_start" value="{:input('get.integral_b_start','')}" style="width: 100px;" placeholder="起始区间">
                            <span style="line-height: 35px;margin: 0 5px;width: unset;">~</span>
                            <input type="text" name="integral_b_end" value="{:input('get.integral_b_end','')}" style="width: 100px;" placeholder="终止区间">
                        </label>
                        <label class="col-sm-3" for="">
                            <span>主题/事件:</span>
                            <input type="text" name="theme_name" value="{:input('get.theme_name','')}" placeholder="请输入主题/事件名称">
                        </label>
                        <label class="col-sm-3" for="">
                            <span>组织机构:</span>
                            <div class="xyqk_input">
                                <input type="text" name="department_check_name" class="department_check_name" value="{:input('get.department_check_name','')}" placeholder="选择组织机构" autocomplete="off">
                                <input type="hidden" name="department_id" value="{:input('get.department_id','')}" class="department_check_id">
                                <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>
                        </label>
                        <label class="col-sm-3" for="">
                            <span>奖扣对象:</span>
                            <div class="xyqk_input">
                                <input type="text" class="user_id_name" value="{:input('get.user_id_name','')}" name="user_id_name" placeholder="请选择">
                                <input type="hidden" name="user_id" value="{:input('get.user_id','')}" class="user_id" value="">
                                <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>
                        </label>

                        <label class="col-sm-3" for=""><span>工号:</span> <input type="text" name="job_number" value="{:input('get.job_number','')}" placeholder="输入工号"></label>
                        <label class="col-sm-3" for=""><span>事件描述:</span> <input type="text" name="event_desc" value="{:input('get.event_desc','')}" placeholder="输入事件描述"></label>
                        <label class="col-sm-3" for="">
                            <span>审核状态:</span>
                            <select name="status" class="status_select" style="width: 220px;">
                                <option class="reset_status_select" value="-1" {if condition="input('status', '-1') == -1"}selected{/if}>选择状态</option>
                                <option value="0" {if condition="input('status', '-1') == 0"}selected{/if} >待初审</option>
                                <option value="1" {if condition="input('status', '-1') == 1"}selected{/if} >待终审</option>
                                <option value="2" {if condition="input('status', '-1') == 2"}selected{/if} >审核通过</option>
                                <option value="3" {if condition="input('status', '-1') == 3"}selected{/if} >作废</option>
                                <option value="4" {if condition="input('status', '-1') == 4"}selected{/if} >拟稿</option>
                            </select>
                        </label>

                        <label class="col-sm-3"><span>奖扣时间:</span>
                            <input type="text" class="layui-input" value="{:input('get.award_deduction_time_all','')}" autocomplete="off" name="award_deduction_time_all" id="award_deduction_time" placeholder="">
                            <input type="hidden" value="{:input('get.award_deduction_time_start','')}" name="award_deduction_time_start">
                            <input type="hidden" value="{:input('get.award_deduction_time_end','')}" name="award_deduction_time_end">
                        </label>
                        <label class="col-sm-3"><span>记录时间:</span>
                            <input type="text" class="layui-input" value="{:input('get.record_time_all','')}" autocomplete="off" name="record_time_all" id="record_time" placeholder="">
                            <input type="hidden" value="{:input('get.record_time_start','')}" name="record_time_start">
                            <input type="hidden" value="{:input('get.record_time_end','')}" name="record_time_end">
                        </label>
                        <label class="col-sm-3">
                            <span>过滤启动分:</span>
                            <select class="select2" name="base_integral" style="width: 220px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                <option value="0" {if condition="input('base_integral', '1') == 0"}selected{/if} >否</option>
                                <option value="1" {if condition="input('base_integral', '1') == 1"}selected{/if} >是</option>
                            </select>
                        </label>
                        <label class="col-sm-3">
                            <span>过滤工龄分:</span>
                            <select class="select2" name="working_age_integral" style="width: 220px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                <option value="0" {if condition="input('working_age_integral', '1') == 0"}selected{/if} >否</option>
                                <option value="1" {if condition="input('working_age_integral', '1') == 1"}selected{/if} >是</option>
                            </select>
                        </label>
                        <!-- <label  style="display:flex; width: 190px;margin-bottom: 0px;line-height: 34px;">
                            <span>过滤启动分:</span>
                            <select class="select2" name="base_integral" style="width: 100px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                <option value="0" selected>否</option>
                                <option value="1">是</option>
                            </select>
                        </label>
                        <label  style="display:flex; width: 190px;margin-bottom: 0px;line-height: 34px;">
                            <span>过滤工龄分:</span>
                            <select class="select2" name="working_age_integral" style="width: 100px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                <option value="0" selected>否</option>
                                <option value="1">是</option>
                            </select>
                        </label> -->
                        <div style="position: absolute;right: 20px;bottom: 20px;">
                            <input type="hidden" name="all" value="1">
                            <button type="submit" class="btn btn-default sreachs"><i class="fa fa-search"></i> 查询</button>
                            <div  class="btn btn-default reset_gjsx"><i class="fa fa-repeat"></i> 重置</div>
                            <!-- <p style="color: red;">点击重置清空所有筛选条件，并且是高级筛选的状态</p> -->
                        </div>
                    </div>
                </form>
            </div>

        </div>        
    </div>

    <div class="box-body table-responsive">
        <div class="tpl-list-table_header">
                <span><i class="glyphicon glyphicon-info-sign" style="color: #1890FF;margin-right: 10px;"></i>日常奖扣查询列表</span>
        </div>
        <table class="table table-bordered table-hover">
            <tr>
                <th>奖扣对象/工号</th>
                <th>奖扣时间</th>
                <th>记录时间</th>
                <th>主题/事件</th>
                <th>A分</th>
                <th>B分</th>
                <th>记录人/初审人/终审人</th>
                <th>审核状态</th>
                <th>事件描述</th>
            </tr>
            {volist name="list" id="v"}
                <tr>
                    <td>{$v.user_name}/{$v.job_number}</td>
                    <td>{:date('Y-m-d',$v.prize_buckle_time)}</td>
                    <td>{:date('Y-m-d H:i',$v.create_time)}</td>
                    <td><a href="{:url('integral/event_info_2021',['id'=>$v.id])}">{$v.theme}/{$v.name}</a></td>
                    <td style='color: {if condition="$v.integral_a >= 0"}#0C0C0C{else}red{/if}' >{$v.integral_a}</td>
                    <td style='color: {if condition="$v.integral_b >= 0"}#0C0C0C{else}red{/if}'>{$v.integral_b}</td>
                    <td>{$v.record_name}/{$v.first_name}/{$v.last_name}</td>
                    <td>
                        {if condition="$v.status eq 0"}
                        待初审
                        {elseif condition="$v.status eq 1"}
                        待终审
                        {elseif condition="$v.status eq 2"}
                        审核通过
                        {elseif condition="$v.status eq 3"}
                        作废
                        {else}
                        拟稿
                        {/if}
                    </td>
                    <td>{$v.event_desc}</td>
                </tr>
            {/volist}
        </table>
    </div>
    <div class="box-footer clearfix">
        {$page_list}
    </div>
</section>

<script>
    var all = "{:input('all',0)}";
    // let show = false;
    var show = false;
    console.log(show);
    if(all == 1){

        let advancedQuery = document.querySelector(".advancedQuery");
        let boxTitle = document.getElementById("box-title");
        let boxTitles_sousuo = document.querySelector(".box-title");
        advancedQuery.style.display = show ? "none" : "block";
        boxTitle.style.display = show ? "flex" : "none";
        boxTitles_sousuo.style.display = show ? "block" : "none";
        Query.innerText = show ? "高级查询" : "普通查询";
        show = !show;
    }
    $('#Query').on('click',function () {
        //console.log(show);
        let advancedQuery = document.querySelector(".advancedQuery");
        let boxTitle = document.getElementById("box-title");
        let boxTitles_sousuo = document.querySelector(".box-title");
        advancedQuery.style.display = show ? "none" : "block";
        boxTitle.style.display = show ? "flex" : "none";
        boxTitles_sousuo.style.display = show ? "block" : "none";
        Query.innerText = show ? "高级查询" : "普通查询";
        show = !show;
    })        
    $(function () {
        $(".select2").select2({language:"zh-CN"});
        $(".status_select").select2({language:"zh-CN"});
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            var nowtime = "{:date('2021-01-01 H:i:s',time())}";
            laydate.render({
                    elem: '#award_deduction_time'
                    , type: 'datetime'
                    // ,min: nowtime //本年
                    ,max: nowtime //本年
                    , range: '~'
                    // , format: 'yyyy年M月d日H时m分s秒'
                    , format: 'yyyy年M月d日'
                    ,change: function(value, date, endDate){
                        var award_deduction_time_start = date.year+'/'+date.month+'/'+date.date;
                        var award_deduction_time_end = endDate.year+'/'+endDate.month+'/'+endDate.date;
                        $("input[name='award_deduction_time_start']").val(award_deduction_time_start);
                        $("input[name='award_deduction_time_end']").val(award_deduction_time_end);
                    }
            });
            laydate.render({
                    elem: '#record_time'
                    , type: 'datetime'
                    // ,min: nowtime //本年
                    ,max: nowtime //本年
                    , range: '~'
                    // , format: 'yyyy年M月d日H时m分s秒'
                    , format: 'yyyy年M月d日'
                    ,change: function(value, date, endDate){
                        var record_time_start = date.year+'/'+date.month+'/'+date.date;
                        var record_time_end = endDate.year+'/'+endDate.month+'/'+endDate.date;
                        $("input[name='record_time_start']").val(record_time_start);
                        $("input[name='record_time_end']").val(record_time_end);
                    }
            });
        })
    })
    // 重置高级搜索 anan
    $(".reset_gjsx").click(function (e) { 
        $(".gjsx").find("input").val("");
        $(".gjsx").find("input[name='event_ids[]']").remove();
        $(".gjsx").find(".reset_status_select").prop("selected",true);
        $(".status_select").select2({language:"zh-CN"});
    });
</script>

<!-- 弹框样式引入 -->
<link rel="stylesheet" href="__STATIC__/global/an_tree_css/an_tree_css.css">
<!-- Modal 弹出层重写 事件多选   -->
<div class="modal fade " id="myModal_things_multiple" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel10">事件选择</h4>
            </div>
            <div class="modal-body">
                <div class="modal-left">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input type="text" name="search_user_name" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                        style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;"><span
                                        class="glyphicon glyphicon-search"></span></button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body">
                        <div class="table-left">
                            <div class="an_tree">

                            </div>
                        </div>
                        <div class="table-right">
                            <div class="an_tree_list">
                                <!-- <div class="an_list_title">

                                </div> -->
                                <div class="an_list_con">
                                    <!-- <div class="an_list_item">
                                        <div class="item_info">
                                            <span class="name">aaa</span>/
                                            <span>88</span>/
                                            <span>部门</span>
                                        </div>
                                        <div class="item_box item_box_check"><i class="fa fa-check"></i></div>
                                    </div> -->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-right">
                    <div class="multiresult_header">
                        <div>已选择<span class="number">0</span>个</div>
                        <div class="header_clear">清空</div>
                    </div>
                    <div class="multiresult_list">
                        <!-- <div class="an_list_item">
                            <div class="item_info">
                                <span class="name">aaa</span>/
                                <span>88</span>/
                                <span>部门</span>
                            </div>
                            <div class="item_box item_box_check"><i class="fa fa-check"></i></div>
                        </div> -->
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary popups_submit" id="submit2">确认</button>
            </div>
        </div>
    </div>
</div>
<!-- 提示操作 事件选择  -->
<script>
    $("#myModal_things_multiple").on("mouseenter",".an_list_item", function () {
        var i = $("#myModal_things_multiple .an_list_con .an_list_item").index(this);
        $("#myModal_things_multiple .content_tips").eq(i).show();
    });
    $("#myModal_things_multiple").on("mouseleave",".an_list_item", function () {
        $("#myModal_things_multiple .content_tips").hide();
    });
    $('#myModal_things_multiple').mousemove(function (e) {
        var xx = e.originalEvent.x;//e.originalEvent.x; || e.originalEvent.layerX || 0
        var yy = e.originalEvent.y;//e.originalEvent.y; || e.originalEvent.layerY || 0;
        $("#myModal_things_multiple .content_tips").css("left", xx);
        $("#myModal_things_multiple .content_tips").css("top", yy);
        // console.log(xx);
        // console.log(yy);
    });
</script>
<!-- 多选弹窗操作 事件多选  -->
<script>
    var now_item_multiple="";//名字输入框
    var input_name="";
    var is_piece="";
    $("body").on("focus",".things_check_multiple",function () {
        // is_piece = $(this).parents(".tab-pane").find(".things_check").attr("is_piece");
        // if (is_piece == "") {
        //     layui.layer.msg("请先选择事件");
        // } else {
            $('#myModal_things_multiple').modal('show');
            now_item_multiple = $(this);
            input_name = "event_ids[]"
            new_right_add();
            check_all();
        // }
    });
    $(".add_message_push").click(function(){
        $('#myModal_things_multiple').modal('show');
        now_item_multiple=$(this).parents(".tab-pane").find(".user_list");
        input_num = $(this).parents(".tab-pane").find(".even_number").val();
        // new_right_add();
    });
    //确认按钮
    $('#myModal_things_multiple .popups_submit').click(function (e) {
        $('#myModal_things_multiple').modal('hide');
        var check_all = $("#myModal_things_multiple .multiresult_list .an_list_item");
        var content="";
        for (let i = 0; i < check_all.length; i++) {
            var input_value = check_all.eq(i).attr("data_id");
            var input_user_name = check_all.eq(i).attr("data_name");
            var input_data_type = check_all.eq(i).attr("data_type");
            content += '<input type="hidden" name="'+input_name+'" data_name="'+input_user_name+'" value="'+input_value+'" data_type="'+input_data_type+'">';
        }
        if (check_all.length > 0) {
            now_item_multiple.val("已选择"+check_all.length+"个事件");
        }else{
            now_item_multiple.val("");
        };
        now_item_multiple.siblings("input[name='"+input_name+"']").remove();
        now_item_multiple.after(content);
    });
    //当弹窗关闭时执行重置弹窗
    $('#myModal_things_multiple').on('hidden.bs.modal', function () {
        //执行一些动作...重置弹窗
        $(".an_tree_list .an_list_title").html("");
        $(".an_tree_list .an_list_con").html("");
        $(".tree_txt_active").removeClass("tree_txt_active");
        $(".an_tree_pack").hide();
        $(".an_tree .fa").removeClass("fa-caret-down").addClass("fa-caret-right");
        $("#myModal_things_multiple input[name='search_user_name']").val("");
        $("#myModal_things_multiple .header_clear").click();
    });
    //已选择，再进行补充选择时添加右侧选中
    function new_right_add(){
        var input = now_item_multiple.siblings("input[name='"+input_name+"']");
        var content = ""
        for (let i = 0; i < input.length; i++) {
            input.eq(i).attr("");
            content += '<div class="an_list_item" data_id="'+input.eq(i).val()+'" data_name="'+input.eq(i).attr("data_name")+'" data_type="'+input.eq(i).attr("data_type")+'" > <div class="item_info"> <span class="name">'+input.eq(i).attr("data_name")+'</span><span class="data_type"> /'+input.eq(i).attr("data_type")+'</span></div> <div class="item_box"><i class="fa fa-remove"></i></div> </div>';
        }
        $("#myModal_things_multiple .multiresult_list").html("");
        $("#myModal_things_multiple .multiresult_list").append(content);
    }
</script>
<!-- 树结构js操作 事件多选  -->
<script>
    $("#myModal_things_multiple .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    //添加中间人员列表
    $("#myModal_things_multiple").on("click", ".an_tree_txt,.search_btn", function () {
        $(".an_tree").find(".tree_txt_active").removeClass("tree_txt_active");
        $(this).addClass("tree_txt_active");
        var department_id = $(this).attr("data_id");
        // var department_name = $(this).html();
        var user_name = $("#myModal_things_multiple input[name='search_user_name']").val();
        console.log(user_name);
        $.ajax({
            type: 'get',
            url: "{:url('base/base_event_child')}",
            data: {'id' : department_id,'search_name' : user_name},
            dataType:"json",
            success: function (data) {
                // var json = JSON.parse(data);
                // console.log(data);
                var content = '';
                var content_tips = '';
                $.each(data, function (index, value) {
                    if (value.is_piece) {
                        var is_piece = '<p>事件属性：<span>计件事件</span></p>';
                    } else {
                        var is_piece = '';
                    }
                    if (value.desc == "") {
                        var desc = '<span>暂无备注信息</span>'
                    } else {
                        var desc = '<span>'+value.desc+'</span>'
                    }
                    content += '<div class="an_list_item" data_id="'+value.id+'" data_name="'+value.name+'" is_piece="'+value.is_piece+'"> <div class="item_box item_box_check"><i class="fa fa-check"></i></div> <div class="item_info"> <span class="name">'+value.name+'</span> <span>'+value.show_cate_name+'</span> </div> </div>';
                    content_tips += '<div class="content_tips"> <p>事件分类：<span>'+value.show_cate_name+'</span></p> <p>分值范围：<span>A分:'+value.integral_a_start+' ~ '+value.integral_a_end+' B分:'+value.integral_b_start+' ~ '+value.integral_b_end+'</span></p>'+is_piece+'<p><p>备注信息：</p><p>'+desc+'</p></p> </div>'
                });
                $('.an_list_con').html("");
                $('.an_list_con').append(content);
                $("#myModal_things_multiple .content_tips").remove();
                $("#myModal_things_multiple").append(content_tips);
                left_add_active();
                check_all();
            }
        })
    });
    // 选中事件
    $("#myModal_things_multiple .an_tree_list").on("click", ".an_list_item", function () {
        $(this).toggleClass("list_item_check");
        var ischeck = $(this).attr("class");
        if (ischeck.indexOf("list_item_check") >= 0) {
            add_check();
        } else {
            del_check($(this).attr("data_id"));
        }
        check_all();
    });
    //全选按钮
    $("#myModal_things_multiple .an_tree_list").on("click", ".all_item_box", function () {
        $(this).toggleClass("all_item_box_check");
        var ischeck = $(this).attr("class");
        var all_item = $("#myModal_things_multiple .an_tree_list .an_list_item");
        if (ischeck.indexOf("all_item_box_check") >= 0) {
            all_item.addClass("list_item_check");
            add_check();
        } else {
            all_item.removeClass("list_item_check")
            for (let i = 0; i < all_item.length; i++) {
                del_check(all_item.eq(i).attr("data_id"));
            }
        }
        check_all();
    });
    //右侧删除事件
    $("#myModal_things_multiple .multiresult_list").on("click", ".item_box", function () {
        var user_id = $(this).parents(".an_list_item ").attr("data_id");
        del_check(user_id);
        check_all();
    });
    //右侧清空监听
    $("#myModal_things_multiple .multiresult_header").on("click", ".header_clear", function () {
        var all_item = $("#myModal_things_multiple .multiresult_list .an_list_item");
        for (let i = 0; i < all_item.length; i++) {
            del_check(all_item.eq(i).attr("data_id"));
        }
        check_all();
    });
    //全选按钮检测
    function check_all(){
        var all_item_num = $("#myModal_things_multiple .an_tree_list .an_list_item").length;
        var checked_item_num = $("#myModal_things_multiple .an_tree_list .list_item_check").length;
        if(all_item_num != 0 && all_item_num == checked_item_num){
            $("#myModal_things_multiple .an_tree_list .all_item_box").addClass("all_item_box_check");
        }else{
            $("#myModal_things_multiple .an_tree_list .all_item_box").removeClass("all_item_box_check");
        };
        //右侧选中人数统计
        var people_num = $("#myModal_things_multiple .multiresult_list .an_list_item").length;
        $("#myModal_things_multiple .multiresult_header .number").html(people_num);
    };
    //添加右侧选中项
    function add_check(){
        var item_ids = [];
        var all_checked_item = $("#myModal_things_multiple .an_list_con").find(".list_item_check");
        var now_checker_item = $("#myModal_things_multiple .multiresult_list .an_list_item");
        for (let i = 0; i < now_checker_item.length; i++) {
            item_ids.push(now_checker_item.eq(i).attr("data_id"));
        }
        for (let i = 0; i < all_checked_item.length; i++) {
            var now_id = all_checked_item.eq(i).attr("data_id");
            var now_data_name = all_checked_item.eq(i).attr("data_name");
            var now_data_type = all_checked_item.eq(i).find("span").eq(1).html();
            if ( $.inArray(now_id,item_ids) < 0 ) {
                var item = '<div class="an_list_item" data_id="'+now_id+'" data_name="'+now_data_name+'" data_type="'+now_data_type+'" > <div class="item_info"> <span class="name">'+now_data_name+'</span><span class="data_type"> /'+now_data_type+'</span></div> <div class="item_box"><i class="fa fa-remove"></i></div> </div>';
                // var new_item = all_checked_item.eq(i).prop("outerHTML");
                $("#myModal_things_multiple .multiresult_list").append(item);
            }
        }
        // console.log(item_ids);
    }
    //左侧第一次生成时检测是否有选中项
    function left_add_active(){
        var left_item_ids = [];
        var left_checked_item = $("#myModal_things_multiple .an_list_con .an_list_item");
        var right_checker_item = $("#myModal_things_multiple .multiresult_list .an_list_item");
        for (let i = 0; i < left_checked_item.length; i++) {
            left_item_ids.push(left_checked_item.eq(i).attr("data_id"));
        }
        for (let i = 0; i < right_checker_item.length; i++) {
            var user_id = right_checker_item.eq(i).attr("data_id");
            if ( $.inArray(user_id,left_item_ids) >= 0 ) {
                $("#myModal_things_multiple .an_list_con .an_list_item[data_id="+user_id+"]").addClass("list_item_check");
            }
        }
    }
    //取消选中项
    function del_check(user_id){
        var left_item_ids = [];
        var right_item_ids = [];
        var left_checked_item = $("#myModal_things_multiple .an_list_con .an_list_item");
        var right_checker_item = $("#myModal_things_multiple .multiresult_list .an_list_item");
        for (let i = 0; i < left_checked_item.length; i++) {
            left_item_ids.push(left_checked_item.eq(i).attr("data_id"));
        }
        for (let i = 0; i < right_checker_item.length; i++) {
            right_item_ids.push(right_checker_item.eq(i).attr("data_id"));
        }
        if ( $.inArray(user_id,left_item_ids) >= 0 ) {
            $("#myModal_things_multiple .an_list_con .an_list_item[data_id="+user_id+"]").removeClass("list_item_check");
        }
        if ( $.inArray(user_id,right_item_ids) >= 0 ) {
            $("#myModal_things_multiple .multiresult_list .an_list_item[data_id="+user_id+"]").remove();
        }
    }
</script>
<!-- 递归填充目录 事件多选  -->
<script>
    var eventList;
    $.ajax({
        type: 'get',
        url: "{:url('base/base_event_cate')}",
        dataType:"json",
        async: false,
        success: function (data) {
            eventList = JSON.parse(data);
        }
    })
    var an_tree = ergodic(eventList);
    $("#myModal_things_multiple .an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        // console.log(data);
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.name + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.name + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>

<!-- Modal 弹出层重写 事件分类选择  -->
<div class="modal fade myModal_things_type" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content" style="height: 633px;width: 510px">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel_things">事件分类选择</h4>
            </div>
            <div class="modal-body" style="width: 504px;">
                <div class="modal-left" style="width: 504px;">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input name="search_user_name" type="text" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                        style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;">
                                    <span class="glyphicon glyphicon-search"></span>
                                </button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body" style="width: 450px;">
                        <div class="table-left" style="width: 100%">
                            <div class="an_tree search_hide">

                            </div>
                            <div class="search_show" style="display: flex;  flex-direction: column;padding: 20px 10px;">

                            </div>
                        </div>
                       
                    </div>
                </div>

            </div>
            <!-- <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary popups_submit">确认</button>
            </div> -->
        </div>
    </div>
    <!-- <div class="content_tips">
        <p>事件分类：<span>工作类事件/ 日常工作类事件</span></p>
        <p>分值范围：<span>A分:0 ~ 0 B分:100 ~ 200 产值:0 ~ 0</span></p>
        <p>事件属性：<span>专审事件 计件事件</span></p>
        <p><p>备注信息：</p><p><span>暂无备注信息</span></p></p>
    </div> -->
</div>
<!-- 单选弹窗操作 事件分类选择  -->
<script>
    var now_item_name;//名字输入框
    var now_item_id;//id输入框
    //当弹窗关闭时执行重置弹窗
    $('.myModal_things_type').on('hidden.bs.modal', function () {
        // 执行一些动作...重置弹窗
        $(".an_tree_list .an_list_con").html("");
        $(".tree_txt_active").removeClass("tree_txt_active");
        $(".an_tree_pack").hide();
        $(".an_tree .fa").removeClass("fa-caret-down").addClass("fa-caret-right");
        $(".myModal_things_type input[name='search_user_name']").val("");
    });
    // 事件分类选择
    $('body').on('focus','.things_type_check', function () {
        $('.myModal_things_type').modal('show');
        now_item_name = $(this);
        now_item_id = $(this).siblings(".things_type_check_id");//节点
    });
</script>
<!-- 树结构js操作 事件分类选择  -->
<script>
    $(".myModal_things_type .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $(".myModal_things_type").on("click", ".an_tree_txt", function () {
        $('.myModal_things_type').modal('hide');
        $(".things_type_check").val($(this).html());
        $(".things_type_check_id").val($(this).attr("data_id"));
    });
    $(".myModal_things_type").on("click", ".search_btn", function () {
        var search_name = $(".myModal_things_type input[name='search_user_name']").val();
        var item = $(".myModal_things_type .an_tree_txt");

        $(".myModal_things_type .search_show").html("");
        if(search_name == ""){
            $(".myModal_things_type .search_hide").show();
            $(".myModal_things_type .search_show").removeClass("an_tree");
        }else{
            $(".myModal_things_type .search_hide").hide();
            $(".myModal_things_type .search_show").show();
            var content = "";
            for (let i = 0; i < item.length; i++) {
                var name = item.eq(i).html();
                if (name.indexOf(search_name) != -1) {
                    content += item.eq(i).prop("outerHTML");
                }
            }
            $(".myModal_things_type .search_show").append(content)
        }
    })
</script>
<!-- 递归填充目录 事件分类选择  -->
<script>
    var an_tree = ergodic(eventList);
    $(".myModal_things_type .an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        // console.log(data);
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.name + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.name + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>


<!-- Modal 弹出层重写 部门单选  id="myModal_single"-->
<div class="modal fade" id="myModal_department_single" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content" style="width:543px;height: 635px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">部门选择</h4>
            </div>
            <div class="modal-body">
                <div class="modal-left" style="width:485px;">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input name="search_user_name" type="text" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                    style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;">
                                    <span class="glyphicon glyphicon-search"></span>
                                </button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body" style="width: 485px">
                        <div class="table-left" style="width: 100%;">
                            <div class="an_tree search_hide">

                            </div>
                            <div class="search_show" style="display: flex;  flex-direction: column;padding: 20px 10px;">

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<style>
.a{
    flex-direction: row;
}
</style>
</div>
<!-- 部门弹窗操作 部门单选   -->
<script>
    var now_item_name;
    var now_item_id;
    $(".department_check_name").focus(function () {
        $('#myModal_department_single').modal('show');
        // double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $(".department_check_id");//节点
        // first_id = $("input[name='first_check_user_id']").val();//id值
        // user_type = 2;
    });
    $(".department_name_less").focus(function () {
        $('#myModal_department_single').modal('show');
        // double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $(".department_id_less");//节点
        // first_id = $("input[name='first_check_user_id']").val();//id值
        // user_type = 2;
    });

</script>
<!-- 树结构js操作 部门单选  -->
<script>
    $("#myModal_department_single .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $("#myModal_department_single").on("click", ".an_tree_txt", function () {
        $('#myModal_department_single').modal('hide');
        now_item_name.val($(this).html());
        now_item_name.attr('value',$(this).html());
        now_item_id.val($(this).attr("data_id"));
    });
    $("#myModal_department_single").on("click", ".search_btn", function () {
        var item = $("#myModal_department_single .an_tree_txt");
        var search_name = $("#myModal_department_single input[name='search_user_name']").val();
        $("#myModal_department_single .search_show").html("");
        if(search_name == ""){
            $("#myModal_department_single .search_hide").show();
            $("#myModal_department_single .search_show").removeClass("an_tree");
        }else{
            $("#myModal_department_single .search_hide").hide();
            $("#myModal_department_single .search_show").show();
            var content = "";
            for (let i = 0; i < item.length; i++) {
                var name = item.eq(i).html();
                if (name.indexOf(search_name) != -1) {
                    content += item.eq(i).prop("outerHTML");
                }
                console.log(name);
            }
            $("#myModal_department_single .search_show").append(content)
        }
        
    });
</script>
<!-- 递归填充目录 部门单选  -->
<script>
    var department = "";
    $.ajax({
        type: 'get',
        url: "{:url('base/base_department_page')}",
        dataType:"json",
        async: false,
        success: function (data) {
            // eventList = JSON.parse(data);
            department = data;
        }
    })
    var an_tree = ergodic(department)
    $("#myModal_department_single .an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>


<!-- Modal 弹出层重写 人员单选  -->
<div class="modal fade" id="myModal_single" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content" style="width: 585px">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" >人员选择</h4>
            </div>
            <div class="modal-body">
                <div class="modal-left">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input name="search_user_name" type="text" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                    style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;">
                                    <span class="glyphicon glyphicon-search"></span>
                                </button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body">
                        <div class="table-left">
                            <div class="an_tree">

                            </div>
                        </div>
                        <div class="table-right">
                            <div class="an_tree_list">
                                <div class="an_list_title">

                                </div>
                                <div class="an_list_con">
                                    <!-- <div class="an_list_item">
                                        <div class="item_info">
                                            <span class="name">aaa</span>/
                                            <span>88</span>/
                                            <span>部门</span>
                                        </div>
                                        <div class="item_box item_box_check"><i class="fa fa-check"></i></div>
                                    </div> -->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary popups_submit">确认</button>
            </div>
        </div>
    </div>

</div>
<!-- 单选弹窗操作  -->
<script>
    var double_max;//扣分上限
    var first_id="";//初审人id
    var last_id="";//终审人id
    var principal_user_id="";//任务负责人id
    var now_item_name;//名字输入框
    var now_item_id;//id输入框
    var user_type;
    //确认按钮
    $('#myModal_single .popups_submit').click(function (e) {
        $('#myModal_single').modal('hide');
        var checked = $(".an_tree_list").find(".list_item_check");
        now_item_name.val(checked.attr("user_name"));
        now_item_id.val(checked.attr("user_id"));
        now_item_name.attr("limits_b",checked.attr("limits_b"))
    });
    //当弹窗关闭时执行重置弹窗
    $('#myModal_single').on('hidden.bs.modal', function () {
        // 执行一些动作...重置弹窗
        $(".an_tree_list .an_list_title").html("");
        $(".an_tree_list .an_list_con").html("");
        $(".tree_txt_active").removeClass("tree_txt_active");
        $(".an_tree_pack").hide();
        $(".an_tree .fa").removeClass("fa-caret-down").addClass("fa-caret-right");
        $("#myModal_single input[name='search_user_name']").val("");
    });
    // 奖扣对象
    $("input[name='user_id_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = 0;
        now_item_name = $(this);
        now_item_id = $("input[name='user_id']");//节点
        user_type = 0;
    });
    // 记录人
    $("input[name='record_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = 0;
        now_item_name = $(this);
        now_item_id = $("input[name='record_user_id']");//节点
        user_type = 0;
    });
    // 初审人
    $("input[name='first_check_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $("input[name='first_check_user_id']");//节点
        last_id = $("input[name='last_check_user_id']").val();//id值
        user_type = 1;
    });
    // 终审人
    $("input[name='last_check_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $("input[name='last_check_user_id']");//节点
        first_id = $("input[name='first_check_user_id']").val();//id值
        user_type = 2;
    });
</script>
<!-- 树结构js操作 单选  -->
<script>
    $("#myModal_single .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $("#myModal_single").on("click", ".an_tree_txt,.search_btn", function () {
        $(".an_tree").find(".tree_txt_active").removeClass("tree_txt_active");
        $(this).addClass("tree_txt_active");
        var department_id = $(this).attr("data_id");
        var department_name = $(this).html();
        var user_name = $("#myModal_single input[name='search_user_name']").val();
        // console.log(user_name);
        $.ajax({
            type: 'get',
            url: "{:url('base/base_department_per')}",
            data: {'department_id' : department_id,'user_name' : user_name},
            dataType:"json",
            success: function (data) {
                // var json = JSON.parse(data);
                // console.log(data);
                var content = '';
                $.each(data, function (index, value) {
                    if(value.limits==undefined){
                         var limits=0;
                    }else{
                        var limits=value.limits.b;
                    }
                    content += '<div class="an_list_item" user_name="'+value.name+'" user_id="'+value.id+'" limits_b="'+limits+'"><div class="item_info"><span class="name">' + value.name + '</span>/<span>' + value.job_number + '</span>/<span>' + value.department_name + '</span></div><div class="item_box "><i class="fa fa-check"></i></div></div>'
                });
                $('.an_list_con').html("");
                $('.an_list_con').append(content);
                $('.an_list_title').html(department_name + data.length + '人');
            }
        })
    });
    $("#myModal_single .an_tree_list").on("click", ".an_list_item", function () {
        $(this).siblings().removeClass("list_item_check");
        $(this).toggleClass("list_item_check")
    })
</script>
<!-- 递归填充目录 单选  -->
<script>
    var an_tree = ergodic(department);
    $("#myModal_single .an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>
<script>
    layui.use(['layer', 'laydate', 'upload'], function(){
        var laydate = layui.laydate;
        var layer = layui.layer;
        var upload = layui.upload;
        var layer_index = '';//加载层
        laydate.render({
            range:true,
            elem: '.lay_date',
        });
        upload.render({
            elem: '#import'
            ,url: "{:url('review_import')}",
            accept:"file",
            exts:'xlsx',
            size:'8192', // 8M大小
            choose:function(obj){
                layer_index = layer.load(2);
            },
            done: function(res){
                layer.close(layer_index);
                if(res.err == 1){
                    // layer.msg(res.msg, {icon:2});
                    layer.open({
                        type: 1,
                        title:'错误信息',
                        skin: 'layui-layer-demo', //样式类名
                        closeBtn: 1, //不显示关闭按钮
                        anim: 2,
                        shadeClose: true, //开启遮罩关闭
                        content: res.msg
                    });
                }else{
                    layer.msg(res.msg, {icon:1}, function(){
                        location.reload();
                    });
                }
            },
            error: function(){
                layer.close(layer_index);
            }
        });
    });
    $('#sort').on('click',function () {
        if(show){
            var url = "{:url('by_condition_2021')}"+'?'+$('#form2').serialize();
        }else{
            var url = "{:url('by_condition_2021')}"+'?'+$('#form1').serialize();
        }
        window.location.href = url;
    })
    $('#import_a').on('click',function () {
        if(show){
            var url = "{:url('daily_2021_export')}"+'?'+$('#form2').serialize();
        }else{
            var url = "{:url('daily_2021_export')}"+'?'+$('#form1').serialize();
        }
        $.amaran({'message':'正在导出,请等待...'});
        window.location.href = url;
    })
</script>

{/block}
